package com.jade.linkong.service.impl;

import com.jade.common.core.text.Convert;
import com.jade.linkong.domain.LkMatterAlarmLog;
import com.jade.linkong.mapper.LkMatterAlarmLogMapper;
import com.jade.linkong.service.ILkMatterAlarmLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 事项警报日志Service业务层处理
 * 
 * @author jade
 * @date 2020-07-23
 */
@Service
public class LkMatterAlarmLogServiceImpl implements ILkMatterAlarmLogService 
{
    @Autowired
    private LkMatterAlarmLogMapper lkMatterAlarmLogMapper;

    /**
     * 查询事项警报日志
     * 
     * @param id 事项警报日志ID
     * @return 事项警报日志
     */
    @Override
    public LkMatterAlarmLog selectLkMatterAlarmLogById(Long id)
    {
        return lkMatterAlarmLogMapper.selectLkMatterAlarmLogById(id);
    }

    /**
     * 查询事项警报日志列表
     * 
     * @param lkMatterAlarmLog 事项警报日志
     * @return 事项警报日志
     */
    @Override
    public List<LkMatterAlarmLog> selectLkMatterAlarmLogList(LkMatterAlarmLog lkMatterAlarmLog)
    {
        return lkMatterAlarmLogMapper.selectLkMatterAlarmLogList(lkMatterAlarmLog);
    }

    /**
     * 新增事项警报日志
     * 
     * @param lkMatterAlarmLog 事项警报日志
     * @return 结果
     */
    @Override
    public int insertLkMatterAlarmLog(LkMatterAlarmLog lkMatterAlarmLog)
    {
        return lkMatterAlarmLogMapper.insertLkMatterAlarmLog(lkMatterAlarmLog);
    }

    /**
     * 修改事项警报日志
     * 
     * @param lkMatterAlarmLog 事项警报日志
     * @return 结果
     */
    @Override
    public int updateLkMatterAlarmLog(LkMatterAlarmLog lkMatterAlarmLog)
    {
        return lkMatterAlarmLogMapper.updateLkMatterAlarmLog(lkMatterAlarmLog);
    }

    /**
     * 删除事项警报日志对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLkMatterAlarmLogByIds(String ids)
    {
        return lkMatterAlarmLogMapper.deleteLkMatterAlarmLogByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除事项警报日志信息
     * 
     * @param id 事项警报日志ID
     * @return 结果
     */
    @Override
    public int deleteLkMatterAlarmLogById(Long id)
    {
        return lkMatterAlarmLogMapper.deleteLkMatterAlarmLogById(id);
    }

    @Override
    public void cleanAlarmLog() {
        lkMatterAlarmLogMapper.cleanAlarmLog();
    }

    @Override
    public Map<String, List<LkMatterAlarmLog>> selectListByProject(LkMatterAlarmLog alarmLog) {
        List<LkMatterAlarmLog> logs = lkMatterAlarmLogMapper.selectListByProject(alarmLog);
        Map<String, List<LkMatterAlarmLog>> map = logs.stream().collect(Collectors.groupingBy(LkMatterAlarmLog::getProjectName));
        return map;
    }
}
